package com.jiezuo.flowable.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author 庞留杰
 * @version V1.0
 * @description
 * @date 2020/8/24 13:42
 **/
public interface MyMapper extends BaseMapper<Map<String, Object>> {

    @SelectProvider(type = MyProvider.class, method = "findUsersAndButtonIds")
    List<Map<String, Object>> findUsersAndButtonIds(String filter);

    @SelectProvider(type = MyProvider.class, method = "findButtons")
    List<Map<String, Object>> findButtons(String filter);

    // "WHERE su.is_delete=0"
    @Select("SELECT  " +
            " su.id, " +
            " su.user_code, " +
            " su.user_name, " +
            " su.real_name  " +
            "FROM sys_user_view su ")
    List<Map<String, Object>> findAllUsers();

    @Select("SELECT " +
            " sur.user_id AS user_id " +
            "FROM sys_user_role sur " +
            "LEFT JOIN sys_role_permission srp ON sur.role_id=srp.role_id " +
            "WHERE srp.permission_id=#{button_id}")
    List<String> findUserIdsByButtonId(@Param("button_id") String button_id);

//    @Select(" SELECT * FROM act_ru_execution WHERE PROC_INST_ID_=#{processInstanceId} " +
//            "  AND (BUSINESS_KEY_='' OR BUSINESS_KEY_ IS NULL)  ORDER BY REV_ ASC ")
//    List<Map<String, Object>> getDeleteExecutions(@Param("processInstanceId") String processInstanceId);

    /*@Insert(" INSERT INTO act_my_rollback(proc_inst_id,task_id,source_act_id,target_act_id,created_by,created_time,updated_by,updated_time,note)" +
            " VALUES(#{proc_inst_id},#{task_id},#{source_act_id},#{target_act_id},#{created_by},#{created_time},#{updated_by},#{updated_time},#{note}) ")
    int insertFallBack(@Param("proc_inst_id") String proc_inst_id,
                       @Param("task_id") String task_id,
                       @Param("source_act_id") String source_act_id,
                       @Param("target_act_id") String target_act_id,
                       @Param("created_by") String created_by,
                       @Param("created_time") Date created_time,
                       @Param("updated_by") String updated_by,
                       @Param("updated_time") Date updated_time,
                       @Param("note") String note
    );*/

}
